home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 326-350 / disk_337 / cmanual / windows.lzh / Windows / Example9.c < prev    next >
C/C++ Source or Header  |  1990-01-30  |  4KB  |  131 lines

  1. /* Example9                                                            */
  2. /* This program will open a normal window with all system gadgets      */
  3. /* connected to it. If you activate the window, the pointer will chage */
  4. /* shapes into a "nice" arrow.                                         */
  5.  
  6.  
  7.  
  8. /* If your program is using Intuition you should include intuition.h: */
  9. #include <intuition/intuition.h>
  10.  
  11.  
  12.  
  13. struct IntuitionBase *IntuitionBase;
  14.  
  15.  
  16.  
  17. /* Declare a pointer to a Window structure: */ 
  18. struct Window *my_window;
  19.  
  20. /* Declare and initialize your NewWindow structure: */
  21. struct NewWindow my_new_window=
  22. {
  23.   50,            /* LeftEdge    x position of the window. */
  24.   50,            /* TopEdge     y positio of the window. */
  25.   200,           /* Width       200 pixels wide. */
  26.   150,           /* Height      150 lines high. */
  27.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  28.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  29.   NULL,          /* IDCMPFlags  No IDCMP flags. */
  30.   SMART_REFRESH| /* Flags       Intuition should refresh the window. */
  31.   WINDOWCLOSE|   /*             Close Gadget. */
  32.   WINDOWDRAG|    /*             Drag gadget. */
  33.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  34.   WINDOWSIZING,  /*             Sizing Gadget. */
  35.   NULL,          /* FirstGadget No Custom Gadgets. */
  36.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  37.   "MY WINDOW",   /* Title       Title of the window. */
  38.   NULL,          /* Screen      Connected to the Workbench Screen. */
  39.   NULL,          /* BitMap      No Custom BitMap. */
  40.   80,            /* MinWidth    We will not allow the window to become */
  41.   30,            /* MinHeight   smaller than 80 x 30, and not bigger */
  42.   300,           /* MaxWidth    than 300 x 200. */
  43.   200,           /* MaxHeight */
  44.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  45. };
  46.  
  47.  
  48.  
  49. /* Declare and initialize Sprite data for the Pointer: */
  50. USHORT chip my_sprite_data[36]=
  51. {
  52.     0x0000, 0x0000, /* Used by Intuition only. */
  53.  
  54.     0x0000, 0x0100,
  55.     0x0000, 0x0300,
  56.     0x0200, 0x0700,
  57.     0x0600, 0x0D00,
  58.     0x0E00, 0x1900,
  59.     0x1E00, 0x31FC,
  60.     0x3FFC, 0x60FE,
  61.     0x7FFE, 0xc003,
  62.     0x3FFE, 0x4001,
  63.     0x1E0E, 0x21F1,
  64.     0x0E0E, 0x1119,
  65.     0x060E, 0x0919,
  66.     0x020E, 0x0519,
  67.     0x000E, 0x0319,
  68.     0x000E, 0x0119,
  69.     0x0000, 0x001F,
  70.  
  71.     0x0000, 0x0000  /* Used by Intuition only. */
  72. };
  73.  
  74.  
  75.  
  76. main()
  77. {
  78.   /* Open the Intuition Library: */
  79.   IntuitionBase = (struct IntuitionBase *)
  80.     OpenLibrary( "intuition.library", 0 );
  81.   
  82.   if( IntuitionBase == NULL )
  83.     exit(); /* Could NOT open the Intuition Library! */
  84.  
  85.  
  86.  
  87.   /* We will now try to open the window: */
  88.   my_window = (struct Window *) OpenWindow( &my_new_window );
  89.   
  90.   /* Have we opened the window succesfully? */
  91.   if(my_window == NULL)
  92.   {
  93.     /* Could NOT open the Window! */
  94.     
  95.     /* Close the Intuition Library since we have opened it: */
  96.     CloseLibrary( IntuitionBase );
  97.  
  98.     exit();  
  99.   }
  100.  
  101.  
  102.  
  103.   /* We will now call the function SetPointer() to change the windows */
  104.   /* default pointer. If you now Activate the window, by clicking */
  105.   /* somewhere inside it, the pointer will change: */
  106.   SetPointer( my_window, my_sprite_data, 16, 16, 0, -7);
  107.  
  108.   /* my_window:       Pointer to the window. */
  109.   /* &my_sprite_data: Pointer to the Sprite Data. */
  110.   /* 16:              Height, 16 lines. */
  111.   /* 16:              Width, 16 pixels. */
  112.   /* 0:               XOffset, left side. (Position of the "Hot Spot") */
  113.   /* -7:              YOffset, 7 lines down.         -"- */
  114.  
  115.  
  116.   /* We have opened the window, and everything seems to be OK. */
  117.   /* Wait for 30 seconds: */
  118.   Delay( 50 * 30);
  119.  
  120.  
  121.  
  122.   /* We should always close the windows we have opened before we leave: */
  123.   CloseWindow( my_window );
  124.  
  125.  
  126.   
  127.   /* Close the Intuition Library since we have opened it: */
  128.   CloseLibrary( IntuitionBase );
  129.   
  130.   /* THE END */
  131. }